DAY11:Disemvowel Trolls


Posted by birdbirdmurmur on 2023-07-24

題目連結:

Disemvowel Trolls

解法:

初版

function disemvowel(str) {
  return str.replace(/[aeiouAEIOU]/g, '');
}

修正版

function disemvowel(str) {
  return str.replace(/[aeiou]/gi, '');
}

筆記:

使用replace做替換
修正版從/g/gi
從全域變成全域不分大小寫


#javascript #Codewars #replace







Related Posts

Golang - 條件式與迴圈

Golang - 條件式與迴圈

CSS Box, Text Shadow

CSS Box, Text Shadow

簡明人月神話:專案管理之道(The Mythical Man-Month)導讀書摘

簡明人月神話:專案管理之道(The Mythical Man-Month)導讀書摘


Comments